﻿namespace TestTool.Tests.Common.Soap
{
    using System;
    using System.Collections.Generic;
    using System.Runtime.CompilerServices;
    using System.Xml;

    public class SoapMessage<T> : ICloneable where T: class
    {
        public SoapMessage(List<XmlElement> header, T obj, byte[] raw)
        {
            this.Header = new List<XmlElement>();
            this.Header.AddRange(header);
            this.Object = obj;
            this.Raw = raw.Clone() as byte[];
        }

        public object Clone()
        {
            return new SoapMessage<T>(this.Header, this.Object, this.Raw);
        }

        public SoapMessage<U> ToSoapMessage<U>() where U: class
        {
            return new SoapMessage<U>(this.Header, this.Object as U, this.Raw);
        }

        public List<XmlElement> Header { get; protected set; }

        public T Object { get; protected set; }

        public byte[] Raw { get; protected set; }
    }
}

